package ar.fiuba.tp7552.buildadmin.webactions.builds;

import java.net.URLDecoder;
import java.util.Collection;

import ar.fiuba.tp7552.buildadmin.model.builds.Responsable;
import ar.fiuba.tp7552.buildadmin.service.ResponsableService;
import ar.fiuba.tp7552.buildadmin.webactions.BaseAction;

public class ResponsableAction extends BaseAction {
	
	private ResponsableService responsableService;
	private String query;
	private Collection<Responsable> responsables;
	
	// ~~ Constructor ====================================================
	
	public ResponsableAction(ResponsableService responsableService) {
		super();
		this.responsableService = responsableService;
	}
	
	
	// ~~ Actions ========================================================
	
	public String find() {
		try {
			String ppp = URLDecoder.decode(query, "ISO-8859-1");
			responsables = responsableService.find(ppp);
		} catch (Exception e) {
			responsables = responsableService.find(query);	
		}
		return BaseAction.SUCCESS;
	}

	// ~~ getters y setters ========================================================

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public Collection<Responsable> getResponsables() {
		return responsables;
	}

	public void setResponsables(Collection<Responsable> responsables) {
		this.responsables = responsables;
	}

}
